#ifndef __FR__LINESPATIALOBJECT__TXX__
#define __FR__LINESPATIALOBJECT__TXX__

namespace fr
{
  // -----------------------------------------------------------------------
  template< class P >
  bool LineSpatialObject< P >::
  ValueAt(
    const TPoint& point,
    double& value,
    unsigned int depth,
    char* name
    ) const
  {
    if( this->IsInside( point, 0, name ) )
    {
      value = this->GetDefaultInsideValue( );
      return( true );
    }
    else
    {
      value = this->GetDefaultOutsideValue( );
      return( false );

    } // fi
  }

  // -----------------------------------------------------------------------
  template< class P >
  bool LineSpatialObject< P >::
  IsEvaluableAt(
    const TPoint& point,
    unsigned int depth,
    char* name
    ) const
  {
    return( this->IsInside( point, depth, name ) );
  }

  // -----------------------------------------------------------------------
  template< class P >
  bool LineSpatialObject< P >::
  IsInside(
    const TPoint& point,
    unsigned int depth,
    char* name
    ) const
  {
    TVector v0 = point - this->m_Point0;
    TVector v1 = this->m_Point1 - this->m_Point0;
    TScalar c = ( v0[ 0 ] * v1[ 1 ] ) - ( v0[ 1 ] * v1[ 0 ] );
    return( c >= 0 );
  }

  // -----------------------------------------------------------------------
  template< class P >
  void LineSpatialObject< P >::
  CopyInformation( const itk::DataObject* data )
  {
    // check if we are the same type
    const Self* source = dynamic_cast< const Self* >( data );
    if( !source )
      return;

    // copy the properties
    this->Superclass::CopyInformation( data );

    // copy the internal info
    this->SetPoint0( source->GetPoint0( ) );
    this->SetPoint1( source->GetPoint1( ) );
  }

  // -----------------------------------------------------------------------
  template< class P >
  LineSpatialObject< P >::
  LineSpatialObject( )
    : Superclass( )
  {
    this->SetTypeName( "LineSpatialObject" );
    this->SetDimension( Self::Dimension );
    this->m_Point0.Fill( TScalar( 0 ) );
    this->m_Point1.Fill( TScalar( 0 ) );
  }

  // -----------------------------------------------------------------------
  template< class P >
  LineSpatialObject< P >::
  ~LineSpatialObject( )
  {
  }

} // ecapseman

#endif // __FR__LINESPATIALOBJECT__TXX__

// eof - $RCSfile$
